#!/bin/bash
set -e
CONFLUENCE_LOG_DIR="/var/atlassian/application-data/confluence/logs"
CONFLUENCE_SERVER_ID=$(grep serverId ${CONFLUENCE_LOG_DIR}/* | tail -1 | awk '{print $NF}')
[[ -z "${CONFLUENCE_SERVER_ID}" ]] && {
    echo "Cannot get Confluence Server ID"
    exit 1
}
java -jar /opt/atlassian-agent.jar \
    -o odo \
    -m odo@qualitysphere.github.io \
    -s "${CONFLUENCE_SERVER_ID}" \
    -p "${1?'Project ID is required'}"
